Skip to content

Return the menu cursor to the entered row when going back - #12644

Open
kmpeeduwee wants to merge 4 commits into
omacom:quattrofrom
kmpeeduwee:menu-back-keeps-cursor
Open

kmpeeduwee wants to merge 4 commits into
omacom:quattrofrom
kmpeeduwee:menu-back-keeps-cursor

Conversation

@kmpeeduwee

@kmpeeduwee kmpeeduwee commented Sep 20, 2026 •

Copy link
Copy Markdown

Pressing Left or Backspace in the menu jumped the cursor to the top of the parent list instead of the row you had just drilled into.

Each history frame now records the entered row, so going back lands on it. If the menu was summoned straight into a submenu, the parent opens on that submenu's row. Coming back from a search drilldown lands on the branch it was under.

Tests: test/shell.d/menu-test.sh covers the row lookup and the goBack wiring.

Fixes #13896

Left and Backspace dropped the cursor to the top of the parent list. Each history frame now records the row that was drilled into, and going back lands on it. Without history the parent opens on the submenu's own row, and a search drilldown returns to the branch it was under.
@llstrk

llstrk commented Sep 24, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: Going back now returns the cursor to the row that was entered, in every case the description names. No navigation regression was found in the tested scope. Cursor position after Left/Backspace, PR head compared with base:

Back from PR head Base
Submenu entered from its row (keyboard or click) That row Top row
Submenu the menu was summoned straight into (no history) The submenu's row in its parent Top row
Search result several levels below the searched menu The branch it sits under Top row
Menu opened through a link row with a target The link row itself Top row
Entered row now hidden by when or disabled Top selectable row Top selectable row

Verified: setActiveMenu rebuilds the list synchronously before placeCursorOn runs, and the deferred revealCursor from that rebuild runs afterwards, so it scrolls to the restored row rather than the top. navStack has no other readers, and it is reset on every open, so no old string frames can reach the new frame.menu / frame.item code.

Optional test improvement: The goBack side of the change is covered only by regular expressions over Menu.qml. Two edits that break the behavior still pass the whole of test/shell.d/menu-test.sh (126 ok, exit 0):

placeCursorOn(itemId) { return; ... }    -> cursor goes back to the top row again
returnTo = returnTo   (frame.item unused) -> Back from a link row misses the link row (target's branch or top row)

Moving the back decision into MenuModel.js (for example backTarget(items, navStack, activeMenu) returning { menu, item }) would let the history frame, the no-history fallback and a target link row be unit tested the same way as nearestRowIndex.

Pre-existing limitation (not introduced by this PR): settleCursor keeps the numeric selectedIndex across later rebuildDisplay() calls, not the item. If a guard result or a live menu edit arrives just after Back and hides or adds a row above the restored one, the cursor stays on the same index and so moves to a neighbouring row:

Back -> rows [A, B, C], cursor on B (index 1)
guard result hides A -> rows [B, C], cursor still index 1 = C

Base shows the same shift for a cursor moved with the arrow keys. It needs a visibility change to land after Back, such as a guard evaluation still running on the first open or a real state change between opens. An unchanged cached guard result does not trigger it. Re-selecting by itemId after a rebuild would remove it, and could be a separate follow-up.


Review information

Test scope: Source review of the PR head and base, plus the Qt Declarative and Quickshell sources the menu relies on. test/shell.d/menu-test.sh ran unchanged on head and base, under Deno's Node compatibility layer rather than Node. Behavior was checked in a headless Qt 6.11.2 QML harness that runs the head and base Menu.qml functions verbatim against a real ListModel and the default menu, with the guard and provider processes and the UI geometry stubbed. No live desktop session was run, so on-screen scrolling and hover were not observed. The PR's files are unchanged on the current quattro tip, but the merge result was not executed.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 566b926 and reproduced on a worker built from the Omarchy ISO, with nothing found that needs changing.

Reproduction. I drove the real menu with keys on the worker in two ways: open it, move down to Style, enter it, press Left; and summon it straight into Style, then press Backspace. On quattro (8b4eae6), and on this branch with the fix reverted, both land the cursor on Apps at the top of the list. On this branch, both land on Style.

Tests. I ran these on the worker, with this branch merged onto quattro:

  • test/shell.d/menu-test.sh passes: 132 tests.
  • The full ./test/shell fails the same 7 files as quattro alone.
  • ./test/cli's one failure, vscode generated theme references current theme file, fails identically on quattro.

Review. This was reviewed by Claude Opus 5.5 and by Codex Medium as a second opinion. Independence between them is not guaranteed. Neither found a defect. Codex agreed on these points:

  • The history frames have one writer and one reader.
  • A link row returns to the link itself.
  • Hidden or disabled rows fall back to the first selectable row.
  • The change is proportionate to the bug.

There are no competing pull requests or open issues for this. #13642 also touches Menu.qml, but not this code.

This is waiting on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 28, 2026
Brings the fix onto current quattro. The only conflict was test/shell.d/menu-test.sh, where quattro dropped every assertion that reads QML source (omacom#16334); this keeps the nearestRowIndex unit tests and leaves out the source-regex assertions that went with them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch had stopped merging cleanly into quattro, so I merged current quattro (7eedd17) into it as c59d064, and it merges cleanly again. The fix itself is unchanged.

The merge. The only conflict was in test/shell.d/menu-test.sh. Since this pull request was opened, #16334 removed every test in that file that reads QML source, and AGENTS.md now says not to test by grepping the source. So I kept your four nearestRowIndex tests and dropped the assertions that regex-matched Menu.qml. Menu.qml and MenuModel.js merged without conflicts.

Reproduction. I ran it on a worker built from the Omarchy ISO and drove the real menu with keys. Style is now the top-level Appearance menu, so these steps use that. I tried two paths. In the first, I opened the menu, moved down to Appearance, pressed Right, then pressed Left. In the second, I summoned the menu straight into Appearance and pressed Backspace. On quattro, which is this tree with the fix taken out, both paths put the cursor on Apps. At c59d064, both put it back on Appearance.

Before, on quattro: back from Appearance, the cursor is on Apps
After, at c59d0647: back from Appearance, the cursor is on Appearance

Tests, all on the worker:

  • test/shell.d/menu-test.sh passes 114 tests. On quattro it passes 110; the difference is the four new nearestRowIndex tests.
  • ./test/cli passes, here and on quattro.
  • ./test/shell fails 4 tests here. All 4 also fail on quattro, which fails one more.

Review. This was reviewed by Claude Opus 5.5, with Codex Medium and muse-wonder High as second opinions. Their independence is not guaranteed. Both found the merge, the test resolution and the change itself correct and proportionate. Both also raised the same edge case. The cursor is put back once, by position. If a menu guard's answer changes, its result can arrive just after you go back and add or remove a row above the one you returned to. The cursor then keeps its position and ends up one row off. It can only happen in that short window, and it is not new: rebuildDisplay() on quattro keeps the cursor's position, not its row, for every rebuild. So I left it out of this pull request. If the maintainer wants it, the fix belongs in rebuildDisplay(), which would need to remember the row rather than its position.

The goBack() wiring has no automated test now that the source regexes are gone. The worker reproduction above is what covers it.

This fixes #13896. Of the open pull requests for that issue, this is the one triage recommended on the issue. It is now waiting on the maintainer.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining feedback concerns test coverage.

Findings

  1. P2 Back navigation stays untested ▶

Summary

The menu now remembers which row opened each submenu and returns the cursor there when going back.

  • Going back returns the menu cursor to the row you entered.

Runtime checks were not run because Quickshell is unavailable.

Reviews (2) · Last reviewed commit: "Test that going back in the real menu la..." · Reviewed by Greptile

Comment thread test/shell.d/menu-test.sh
Comment on lines +427 to +430
assertEqual(menu.nearestRowIndex(backItems, rootRows, 'learn'), 1, 'menu back lands on the row that was entered')
assertEqual(menu.nearestRowIndex(backItems, rootRows, 'style.bar.position'), 0, 'menu back from a search drilldown lands on the branch it was under')
assertEqual(menu.nearestRowIndex(backItems, rootRows, 'missing'), -1, 'menu back leaves the cursor alone for a row it cannot find')
assertEqual(menu.nearestRowIndex(backItems, [], 'style'), -1, 'menu back copes with an empty list')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Back navigation stays untested

These tests call only nearestRowIndex; they never enter a submenu or call goBack. Removing the new placeCursorOn call would bring back the original bug while every added assertion still passed. Add a behavior test that enters a non-first row, goes back, and checks the selected row. Include a link whose row differs from its target to check the saved history frame too.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 16, 2026
omarchybot and others added 2 commits November 17, 2026 02:34
Only MenuModel.js conflicted: quattro added altVariant and altVariantIds where this branch added nearestRowIndex, so both are kept side by side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The nearestRowIndex tests pass even with the placeCursorOn call removed from goBack, so nothing caught the bug coming back. The fixture loads the real Menu.qml, goes back out of Appearance after entering it and after being summoned into it, and fails on quattro with the cursor on Apps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch had stopped merging cleanly into quattro again, so I merged current quattro (3b36b9e) into it as 0565cfd. The only conflict was in shell/plugins/menu/MenuModel.js: quattro added altVariant and altVariantIds where this branch adds nearestRowIndex, so both are kept side by side. The fix itself is unchanged.

A test for the fix. The four nearestRowIndex tests still pass with the placeCursorOn call taken out of goBack(), as Greptile pointed out, so nothing would have caught the bug coming back. quattro can now load the real Menu.qml in a test fixture, so 06ff768 adds test/shell.d/fixtures/menu-back/, run at the end of menu-test.sh. It enters Appearance from the top-level menu and goes back, then summons the menu straight into Appearance and goes back, and expects the cursor on Appearance both times.

Reproduction, on a worker built from the Omarchy ISO, driving the real menu with keys: open it, move down to Appearance, press Right, then Left; and omarchy-menu summon appearance, then Backspace. With quattro's Menu.qml both paths put the cursor on Apps. At 06ff768 both put it back on Appearance.

Before, with quattro's Menu.qml: back from Appearance, the cursor is on Apps
After, at 06ff768f: back from Appearance, the cursor is on Appearance

Tests, all on the worker:

  • test/shell.d/menu-test.sh passes 120 tests. With quattro's Menu.qml the new fixture fails: going back from Appearance lands on Apps.
  • ./test/cli passes.
  • ./test/shell: 9 of 427 files failed in the full run. Five of them (ascii, branding-about-animation, first-run, runtime-smoke, provision-owner-keyboard) fail the same way on quattro when run alone. The other four (channel-switch, screenrecording-process, ssh-reconnect, t3code-install) pass when run alone, on this branch and on quattro. None of them touch the menu.

Review. This was reviewed by Claude Opus 5.5, with Codex Medium and muse-wonder High as second opinions. Their independence is not guaranteed. Both found nothing to change. They checked the merge resolution, and that this branch still works with the click-into-submenu selection #18565 added to setActiveMenu(). They also found the new fixture sound: it fails only for the bug and does not depend on timing.

This fixes #13896, and of the open pull requests for that issue it is still the one triage recommended there. It is now waiting on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Menu: Left/Backspace from a submenu always returns to the first row, discarding the parent selection (8 open PRs, no issue)

3 participants